#cmake最小版本限定
if (WIN32)
    cmake_minimum_required(VERSION 3.12)
elseif (APPLE)
    cmake_minimum_required(VERSION 3.17)
elseif (UNIX)
    cmake_minimum_required(VERSION 3.17)
endif ()

#工程名字
PROJECT(RapidOcr VERSION 1.0)

#获取CPU架构、系统、系统版本
MESSAGE(STATUS "--Get Base System Information........")
MESSAGE(STATUS "--CPU:${CMAKE_SYSTEM_PROCESSOR}")
MESSAGE(STATUS "--System type:${CMAKE_SYSTEM_NAME}")
MESSAGE(STATUS "--System version:${CMAKE_SYSTEM_VERSION}")

IF (CMAKE_CXX_COMPILER_LOADED)
	MESSAGE(STATUS "--CMAKE_CXX_COMPILER:" ${CMAKE_CXX_COMPILER})
	MESSAGE(STATUS "--CMAKE_CXX_COMPILER_VERSION:" ${CMAKE_CXX_COMPILER_VERSION})
	MESSAGE(STATUS "--CMAKE_CXX_FLAGS:" ${CMAKE_CXX_FLAGS})
ENDIF()

#NCNN引擎开关设置
OPTION(ENGINE_NCNN "Use Ncnn Engine!" OFF)
#ONNX引擎开关设置
OPTION(ENGINE_ONNX "Use Onnx Engine!" ON)

#USE CPU/GPU/CUDA/DIRECTML/VULKAN
IF (ENGINE_ONNX)
	OPTION(USE_CPU "" ON)
	OPTION(USE_GPU "" OFF)
	IF (USE_GPU)
		OPTION(ONNX_USE_CUDA "" ON)
		OPTION(ONNX_USE_DIRECTML "" OFF)
	ENDIF()
ELSEIF (ENGINE_NCNN)
	OPTION(USE_CPU "" ON)
	OPTION(USE_GPU "" OFF)
	IF (USE_GPU)
		OPTION(USE_VULKAN "" ON)
	ENDIF()
ENDIF()

#OCR_OUTPUT编译输出类型
OPTION(OCR_OUTPUT_BIN "Use build bin program!" ON)
OPTION(OCR_OUTPUT_LIB "Use build shared lib!" ON)
OPTION(OCR_OUTPUT_JNI "Use build static lib!" ON)

IF (OCR_OUTPUT_LIB)
	#BUILD_LIB_TYPE编译库类型
	OPTION(BUILD_STATIC "Use build static lib!" OFF)
	OPTION(BUILD_SHARED "Use build static lib!" ON)
ENDIF()

#set(CMAKE_CXX_STANDARD 17)
add_definitions(-DUNICODE -D_UNICODE)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    add_definitions("-Wall -g -O0")
else ()
    add_definitions("-Wall")
endif ()

SET(POSITION_INDEPENDENT_CODE True)
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)


#默认.h/.hpp文件路径,
INCLUDE_DIRECTORIES(
	"core/include"
	"components/include"
	)

#根据引擎选择引入构建脚本
IF (ENGINE_ONNX)
	INCLUDE(cmake/EngineOnnxruntime.cmake)
ELSE(ENGINE_NCNN)
	INCLUDE(cmake/EngineNcnn.cmake)
ENDIF()
INCLUDE(cmake/FindDepend.cmake)
#引入CORE构建脚本
INCLUDE(cmake/CoreDepend.cmake)
#引入扩展库构建脚本
INCLUDE(components/ComponentLists.cmake)


